home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / SCSI.h < prev    next >
Text File  |  1995-07-06  |  44KB  |  1,065 lines

  1. /*
  2.      File:        SCSI.h
  3.  
  4.      Contains:    SCSI Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __SCSI__
  21. #define __SCSI__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __MIXEDMODE__
  30. #include <MixedMode.h>
  31. #endif
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. #if PRAGMA_ALIGN_SUPPORTED
  38. #pragma options align=mac68k
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT_SUPPORTED
  42. #pragma import on
  43. #endif
  44.  
  45.  
  46. enum {
  47.     scInc                        = 1,
  48.     scNoInc                        = 2,
  49.     scAdd                        = 3,
  50.     scMove                        = 4,
  51.     scLoop                        = 5,
  52.     scNop                        = 6,
  53.     scStop                        = 7,
  54.     scComp                        = 8
  55. };
  56.  
  57. /* SCSI Manager errors */
  58. enum {
  59.     scCommErr                    = 2,                            /* communications error, operation timeout */
  60.     scArbNBErr                    = 3,                            /* arbitration timeout waiting for not BSY */
  61.     scBadParmsErr                = 4,                            /* bad parameter or TIB opcode */
  62.     scPhaseErr                    = 5,                            /* SCSI bus not in correct phase for attempted operation */
  63.     scCompareErr                = 6,                            /* data compare error */
  64.     scMgrBusyErr                = 7,                            /* SCSI Manager busy  */
  65.     scSequenceErr                = 8,                            /* attempted operation is out of sequence */
  66.     scBusTOErr                    = 9,                            /* CPU bus timeout */
  67.     scComplPhaseErr                = 10                            /* SCSI bus wasn't in Status phase */
  68. };
  69.  
  70. /* Signatures */
  71. enum {
  72.     sbSIGWord                    = 0x4552,                        /* signature word for Block 0 ('ER') */
  73.     sbMac                        = 1,                            /* system type for Mac */
  74.     pMapSIG                        = 0x504D,                        /* partition map signature ('PM') */
  75.     pdSigWord                    = 0x5453
  76. };
  77.  
  78. enum {
  79.     oldPMSigWord                = pdSigWord,
  80.     newPMSigWord                = pMapSIG
  81. };
  82.  
  83. /* Driver Descriptor Map */
  84. struct Block0 {
  85.     unsigned short                    sbSig;                        /* unique value for SCSI block 0 */
  86.     unsigned short                    sbBlkSize;                    /* block size of device */
  87.     unsigned long                    sbBlkCount;                    /* number of blocks on device */
  88.     unsigned short                    sbDevType;                    /* device type */
  89.     unsigned short                    sbDevId;                    /* device id */
  90.     unsigned long                    sbData;                        /* not used */
  91.     unsigned short                    sbDrvrCount;                /* driver descriptor count */
  92.     unsigned long                    ddBlock;                    /* 1st driver's starting block */
  93.     unsigned short                    ddSize;                        /* size of 1st driver (512-byte blks) */
  94.     unsigned short                    ddType;                        /* system type (1 for Mac+) */
  95.     unsigned short                    ddPad[243];                    /* ARRAY[0..242] OF INTEGER; not used */
  96. };
  97. typedef struct Block0 Block0;
  98.  
  99. /*Driver descriptor*/
  100. struct DDMap {
  101.     unsigned long                    ddBlock;                    /* 1st driver's starting block */
  102.     unsigned short                    ddSize;                        /* size of 1st driver (512-byte blks) */
  103.     unsigned short                    ddType;                        /* system type (1 for Mac+) */
  104. };
  105. typedef struct DDMap DDMap;
  106.  
  107. /* Partition Map Entry */
  108. struct Partition {
  109.     unsigned short                    pmSig;                        /* unique value for map entry blk */
  110.     unsigned short                    pmSigPad;                    /* currently unused */
  111.     unsigned long                    pmMapBlkCnt;                /* # of blks in partition map */
  112.     unsigned long                    pmPyPartStart;                /* physical start blk of partition */
  113.     unsigned long                    pmPartBlkCnt;                /* # of blks in this partition */
  114.     unsigned char                    pmPartName[32];                /* ASCII partition name */
  115.     unsigned char                    pmParType[32];                /* ASCII partition type */
  116.     unsigned long                    pmLgDataStart;                /* log. # of partition's 1st data blk */
  117.     unsigned long                    pmDataCnt;                    /* # of blks in partition's data area */
  118.     unsigned long                    pmPartStatus;                /* bit field for partition status */
  119.     unsigned long                    pmLgBootStart;                /* log. blk of partition's boot code */
  120.     unsigned long                    pmBootSize;                    /* number of bytes in boot code */
  121.     unsigned long                    pmBootAddr;                    /* memory load address of boot code */
  122.     unsigned long                    pmBootAddr2;                /* currently unused */
  123.     unsigned long                    pmBootEntry;                /* entry point of boot code */
  124.     unsigned long                    pmBootEntry2;                /* currently unused */
  125.     unsigned long                    pmBootCksum;                /* checksum of boot code */
  126.     unsigned char                    pmProcessor[16];            /* ASCII for the processor type */
  127.     unsigned short                    pmPad[188];                    /* ARRAY[0..187] OF INTEGER; not used */
  128. };
  129. typedef struct Partition Partition;
  130.  
  131. /* TIB instruction */
  132. struct SCSIInstr {
  133.     unsigned short                    scOpcode;
  134.     long                            scParam1;
  135.     long                            scParam2;
  136. };
  137. typedef struct SCSIInstr SCSIInstr;
  138.  
  139. extern pascal OSErr SCSIReset(void)
  140.  TWOWORDINLINE(0x4267, 0xA815);
  141. extern pascal OSErr SCSIGet(void)
  142.  THREEWORDINLINE(0x3F3C, 0x0001, 0xA815);
  143. extern pascal OSErr SCSISelect(short targetID)
  144.  THREEWORDINLINE(0x3F3C, 0x0002, 0xA815);
  145. extern pascal OSErr SCSICmd(Ptr buffer, short count)
  146.  THREEWORDINLINE(0x3F3C, 0x0003, 0xA815);
  147. extern pascal OSErr SCSIRead(Ptr tibPtr)
  148.  THREEWORDINLINE(0x3F3C, 0x0005, 0xA815);
  149. extern pascal OSErr SCSIRBlind(Ptr tibPtr)
  150.  THREEWORDINLINE(0x3F3C, 0x0008, 0xA815);
  151. extern pascal OSErr SCSIWrite(Ptr tibPtr)
  152.  THREEWORDINLINE(0x3F3C, 0x0006, 0xA815);
  153. extern pascal OSErr SCSIWBlind(Ptr tibPtr)
  154.  THREEWORDINLINE(0x3F3C, 0x0009, 0xA815);
  155. extern pascal OSErr SCSIComplete(short *stat, short *message, unsigned long wait)
  156.  THREEWORDINLINE(0x3F3C, 0x0004, 0xA815);
  157. extern pascal short SCSIStat(void)
  158.  THREEWORDINLINE(0x3F3C, 0x000A, 0xA815);
  159. extern pascal OSErr SCSISelAtn(short targetID)
  160.  THREEWORDINLINE(0x3F3C, 0x000B, 0xA815);
  161. extern pascal OSErr SCSIMsgIn(short *message)
  162.  THREEWORDINLINE(0x3F3C, 0x000C, 0xA815);
  163. extern pascal OSErr SCSIMsgOut(short message)
  164.  THREEWORDINLINE(0x3F3C, 0x000D, 0xA815);
  165. /*——————————————————————— New SCSI Manager Interface ———————————————————————*/
  166.  
  167. enum {
  168.     scsiVERSION                    = 43
  169. };
  170.  
  171. /* SCSI Manager function codes */
  172. enum {
  173.     SCSINop                        = 0x00,                            /* Execute nothing                                         */
  174.     SCSIExecIO                    = 0x01,                            /* Execute the specified IO                             */
  175.     SCSIBusInquiry                = 0x03,                            /* Get parameters for entire path of HBAs                 */
  176.     SCSIReleaseQ                = 0x04,                            /* Release the frozen SIM queue for particular LUN         */
  177.     SCSIAbortCommand            = 0x10,                            /* Abort the selected Control Block                      */
  178.     SCSIResetBus                = 0x11,                            /* Reset the SCSI bus                                      */
  179.     SCSIResetDevice                = 0x12,                            /* Reset the SCSI device                                  */
  180.     SCSITerminateIO                = 0x13,                            /* Terminate any pending IO                              */
  181.     SCSIGetVirtualIDInfo        = 0x80,                            /* Find out which bus old ID is on                         */
  182.     SCSILoadDriver                = 0x82,                            /* Load a driver for a device ident                     */
  183.     SCSIOldCall                    = 0x84,                            /* XPT->SIM private call for old-API                     */
  184.     SCSICreateRefNumXref        = 0x85,                            /* Register a DeviceIdent to drvr RefNum xref             */
  185.     SCSILookupRefNumXref        = 0x86,                            /* Get DeviceIdent to drvr RefNum xref                     */
  186.     SCSIRemoveRefNumXref        = 0x87,                            /* Remove a DeviceIdent to drvr RefNum xref             */
  187.     SCSIRegisterWithNewXPT        = 0x88,                            /* XPT has changed - SIM needs to re-register itself     */
  188.     vendorUnique                = 0xC0                            /* 0xC0 thru 0xFF */
  189. };
  190.  
  191. /* SCSI Callback Procedure Prototypes */
  192. /* SCSIInterruptPollProcPtr is obsolete (use SCSIInterruptProcPtr) but still here for compatibility */
  193. typedef pascal void (*SCSICallbackProcPtr)(void *scsiPB);
  194. typedef void (*AENCallbackProcPtr)(void);
  195. typedef OSErr (*SIMInitProcPtr)(Ptr SIMinfoPtr);
  196. typedef void (*SIMActionProcPtr)(void *scsiPB, Ptr SIMGlobals);
  197. typedef void (*SCSIProcPtr)(void);
  198. typedef void (*SCSIMakeCallbackProcPtr)(void *scsiPB);
  199. typedef long (*SCSIInterruptPollProcPtr)(Ptr SIMGlobals);
  200. typedef long (*SCSIInterruptProcPtr)(Ptr SIMGlobals);
  201.  
  202. #if GENERATINGCFM
  203. typedef UniversalProcPtr SCSICallbackUPP;
  204. typedef UniversalProcPtr AENCallbackUPP;
  205. typedef UniversalProcPtr SIMInitUPP;
  206. typedef UniversalProcPtr SIMActionUPP;
  207. typedef UniversalProcPtr SCSIUPP;
  208. typedef UniversalProcPtr SCSIMakeCallbackUPP;
  209. typedef UniversalProcPtr SCSIInterruptPollUPP;
  210. typedef UniversalProcPtr SCSIInterruptUPP;
  211. #else
  212. typedef SCSICallbackProcPtr SCSICallbackUPP;
  213. typedef AENCallbackProcPtr AENCallbackUPP;
  214. typedef SIMInitProcPtr SIMInitUPP;
  215. typedef SIMActionProcPtr SIMActionUPP;
  216. typedef SCSIProcPtr SCSIUPP;
  217. typedef SCSIMakeCallbackProcPtr SCSIMakeCallbackUPP;
  218. typedef SCSIInterruptPollProcPtr SCSIInterruptPollUPP;
  219. typedef SCSIInterruptProcPtr SCSIInterruptUPP;
  220. #endif
  221.  
  222. enum {
  223.     uppSCSICallbackProcInfo = kPascalStackBased
  224.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void*))),
  225.     uppAENCallbackProcInfo = kCStackBased,
  226.     uppSIMInitProcInfo = kCStackBased
  227.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  228.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr))),
  229.     uppSIMActionProcInfo = kCStackBased
  230.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void*)))
  231.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr))),
  232.     uppSCSIProcInfo = kCStackBased,
  233.     uppSCSIMakeCallbackProcInfo = kCStackBased
  234.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void*))),
  235.     uppSCSIInterruptPollProcInfo = kCStackBased
  236.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  237.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr))),
  238.     uppSCSIInterruptProcInfo = kCStackBased
  239.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  240.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr)))
  241. };
  242.  
  243. #if GENERATINGCFM
  244. #define NewSCSICallbackProc(userRoutine)        \
  245.         (SCSICallbackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSICallbackProcInfo, GetCurrentArchitecture())
  246. #define NewAENCallbackProc(userRoutine)        \
  247.         (AENCallbackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppAENCallbackProcInfo, GetCurrentArchitecture())
  248. #define NewSIMInitProc(userRoutine)        \
  249.         (SIMInitUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIMInitProcInfo, GetCurrentArchitecture())
  250. #define NewSIMActionProc(userRoutine)        \
  251.         (SIMActionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIMActionProcInfo, GetCurrentArchitecture())
  252. #define NewSCSIProc(userRoutine)        \
  253.         (SCSIUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIProcInfo, GetCurrentArchitecture())
  254. #define NewSCSIMakeCallbackProc(userRoutine)        \
  255.         (SCSIMakeCallbackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIMakeCallbackProcInfo, GetCurrentArchitecture())
  256. #define NewSCSIInterruptPollProc(userRoutine)        \
  257.         (SCSIInterruptPollUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIInterruptPollProcInfo, GetCurrentArchitecture())
  258. #define NewSCSIInterruptProc(userRoutine)        \
  259.         (SCSIInterruptUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIInterruptProcInfo, GetCurrentArchitecture())
  260. #else
  261. #define NewSCSICallbackProc(userRoutine)        \
  262.         ((SCSICallbackUPP) (userRoutine))
  263. #define NewAENCallbackProc(userRoutine)        \
  264.         ((AENCallbackUPP) (userRoutine))
  265. #define NewSIMInitProc(userRoutine)        \
  266.         ((SIMInitUPP) (userRoutine))
  267. #define NewSIMActionProc(userRoutine)        \
  268.         ((SIMActionUPP) (userRoutine))
  269. #define NewSCSIProc(userRoutine)        \
  270.         ((SCSIUPP) (userRoutine))
  271. #define NewSCSIMakeCallbackProc(userRoutine)        \
  272.         ((SCSIMakeCallbackUPP) (userRoutine))
  273. #define NewSCSIInterruptPollProc(userRoutine)        \
  274.         ((SCSIInterruptPollUPP) (userRoutine))
  275. #define NewSCSIInterruptProc(userRoutine)        \
  276.         ((SCSIInterruptUPP) (userRoutine))
  277. #endif
  278.  
  279. #if GENERATINGCFM
  280. #define CallSCSICallbackProc(userRoutine, scsiPB)        \
  281.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSCSICallbackProcInfo, (scsiPB))
  282. #define CallAENCallbackProc(userRoutine)        \
  283.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppAENCallbackProcInfo)
  284. #define CallSIMInitProc(userRoutine, SIMinfoPtr)        \
  285.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSIMInitProcInfo, (SIMinfoPtr))
  286. #define CallSIMActionProc(userRoutine, scsiPB, SIMGlobals)        \
  287.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSIMActionProcInfo, (scsiPB), (SIMGlobals))
  288. #define CallSCSIProc(userRoutine)        \
  289.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSCSIProcInfo)
  290. #define CallSCSIMakeCallbackProc(userRoutine, scsiPB)        \
  291.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSCSIMakeCallbackProcInfo, (scsiPB))
  292. #define CallSCSIInterruptPollProc(userRoutine, SIMGlobals)        \
  293.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSCSIInterruptPollProcInfo, (SIMGlobals))
  294. #define CallSCSIInterruptProc(userRoutine, SIMGlobals)        \
  295.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSCSIInterruptProcInfo, (SIMGlobals))
  296. #else
  297. #define CallSCSICallbackProc(userRoutine, scsiPB)        \
  298.         (*(userRoutine))((scsiPB))
  299. #define CallAENCallbackProc(userRoutine)        \
  300.         (*(userRoutine))()
  301. #define CallSIMInitProc(userRoutine, SIMinfoPtr)        \
  302.         (*(userRoutine))((SIMinfoPtr))
  303. #define CallSIMActionProc(userRoutine, scsiPB, SIMGlobals)        \
  304.         (*(userRoutine))((scsiPB), (SIMGlobals))
  305. #define CallSCSIProc(userRoutine)        \
  306.         (*(userRoutine))()
  307. #define CallSCSIMakeCallbackProc(userRoutine, scsiPB)        \
  308.         (*(userRoutine))((scsiPB))
  309. #define CallSCSIInterruptPollProc(userRoutine, SIMGlobals)        \
  310.         (*(userRoutine))((SIMGlobals))
  311. #define CallSCSIInterruptProc(userRoutine, SIMGlobals)        \
  312.         (*(userRoutine))((SIMGlobals))
  313. #endif
  314.  
  315. enum {
  316.     handshakeDataLength            = 8,                            /* Handshake data length */
  317.     maxCDBLength                = 16,                            /* Space for the CDB bytes/pointer */
  318.     vendorIDLength                = 16                            /* ASCII string len for Vendor ID  */
  319. };
  320.  
  321. /* Define DeviceIdent structure */
  322. struct DeviceIdent {
  323.     UInt8                            diReserved;                    /* reserved                 */
  324.     UInt8                            bus;                        /* SCSI - Bus Number        */
  325.     UInt8                            targetID;                    /* SCSI - Target SCSI ID    */
  326.     UInt8                            LUN;                        /* SCSI - LUN                  */
  327. };
  328. typedef struct DeviceIdent DeviceIdent;
  329.  
  330. /* Command Descriptor Block structure */
  331. union CDB {
  332.     UInt8                            *cdbPtr;                    /* pointer to the CDB, or */
  333.     UInt8                            cdbBytes[maxCDBLength];        /* the actual CDB to send */
  334. };
  335. typedef union CDB CDB, *CDBPtr;
  336.  
  337. /* Scatter/gather list element */
  338. struct SGRecord {
  339.     Ptr                                SGAddr;
  340.     UInt32                            SGCount;
  341. };
  342. typedef struct SGRecord SGRecord;
  343.  
  344. /* SCSI Phases (used by SIMs to support the Original SCSI Manager */
  345.  
  346. enum {
  347.     kDataOutPhase,                                                /* Encoded MSG, C/D, I/O bits */
  348.     kDataInPhase,
  349.     kCommandPhase,
  350.     kStatusPhase,
  351.     kPhaseIllegal0,
  352.     kPhaseIllegal1,
  353.     kMessageOutPhase,
  354.     kMessageInPhase,
  355.     kBusFreePhase,                                                /* Additional Phases */
  356.     kArbitratePhase,
  357.     kSelectPhase,
  358.     kMessageInPhaseNACK                                            /* Message In Phase with ACK hanging on the bus */
  359. };
  360.  
  361. #define SCSIPBHdr                 \
  362.     struct SCSIHdr * qLink;        \
  363.     short    scsiReserved1;            \
  364.     UInt16    scsiPBLength;            \
  365.     UInt8    scsiFunctionCode;        \
  366.     UInt8    scsiReserved2;            \
  367.     OSErr    scsiResult;                \
  368.     DeviceIdent    scsiDevice;        \
  369.     SCSICallbackUPP    scsiCompletion;     \
  370.     UInt32    scsiFlags;                \
  371.     UInt8 *    scsiDriverStorage;        \
  372.     Ptr    scsiXPTprivate;            \
  373.     long    scsiReserved3;
  374. struct SCSIHdr {
  375.     struct SCSIHdr                    *qLink;
  376.     short                            scsiReserved1;
  377.     UInt16                            scsiPBLength;
  378.     UInt8                            scsiFunctionCode;
  379.     UInt8                            scsiReserved2;
  380.     OSErr                            scsiResult;
  381.     DeviceIdent                        scsiDevice;
  382.     SCSICallbackUPP                    scsiCompletion;
  383.     UInt32                            scsiFlags;
  384.     UInt8                            *scsiDriverStorage;
  385.     Ptr                                scsiXPTprivate;
  386.     long                            scsiReserved3;
  387. };
  388. typedef struct SCSIHdr SCSIHdr;
  389.  
  390. struct SCSI_PB {
  391.     struct SCSIHdr                    *qLink;
  392.     short                            scsiReserved1;
  393.     UInt16                            scsiPBLength;
  394.     UInt8                            scsiFunctionCode;
  395.     UInt8                            scsiReserved2;
  396.     OSErr                            scsiResult;
  397.     DeviceIdent                        scsiDevice;
  398.     SCSICallbackUPP                    scsiCompletion;
  399.     UInt32                            scsiFlags;
  400.     UInt8                            *scsiDriverStorage;
  401.     Ptr                                scsiXPTprivate;
  402.     long                            scsiReserved3;
  403. };
  404. typedef struct SCSI_PB SCSI_PB;
  405.  
  406. #define SCSI_IO_Macro             \
  407.     SCSIPBHdr                        \
  408.     UInt16    scsiResultFlags;        \
  409.     UInt16    scsiReserved3pt5;        \
  410.     UInt8 *    scsiDataPtr;            \
  411.     UInt32    scsiDataLength;            \
  412.     UInt8 *    scsiSensePtr;            \
  413.     UInt8    scsiSenseLength;            \
  414.     UInt8    scsiCDBLength;            \
  415.     UInt16    scsiSGListCount;        \
  416.     UInt32    scsiReserved4;            \
  417.     UInt8    scsiSCSIstatus;            \
  418.     SInt8    scsiSenseResidual;        \
  419.     UInt16    scsiReserved5;            \
  420.     long    scsiDataResidual;            \
  421.     CDB    scsiCDB;                    \
  422.     long    scsiTimeout;                \
  423.     UInt8 *    scsiReserved5pt5;        \
  424.     UInt16    scsiReserved5pt6;        \
  425.     UInt16    scsiIOFlags;            \
  426.     UInt8    scsiTagAction;            \
  427.     UInt8    scsiReserved6;            \
  428.     UInt16    scsiReserved7;            \
  429.     UInt16    scsiSelectTimeout;        \
  430.     UInt8    scsiDataType;            \
  431.     UInt8    scsiTransferType;        \
  432.     UInt32    scsiReserved8;            \
  433.     UInt32    scsiReserved9;            \
  434.     UInt16    scsiHandshake[handshakeDataLength];     \
  435.     UInt32    scsiReserved10;            \
  436.     UInt32    scsiReserved11;            \
  437.     struct SCSI_IO *scsiCommandLink;     \
  438.                                 \
  439.     UInt8    scsiSIMpublics[8];        \
  440.     UInt8    scsiAppleReserved6[8];     \
  441.                                 \
  442.                                 \
  443.                                 \
  444.     UInt16    scsiCurrentPhase;        \
  445.     short    scsiSelector;            \
  446.     OSErr    scsiOldCallResult;        \
  447.     UInt8    scsiSCSImessage;            \
  448.     UInt8    XPTprivateFlags;            \
  449.     UInt8    XPTextras[12];
  450. struct SCSI_IO {
  451.     struct SCSIHdr                    *qLink;
  452.     short                            scsiReserved1;
  453.     UInt16                            scsiPBLength;
  454.     UInt8                            scsiFunctionCode;
  455.     UInt8                            scsiReserved2;
  456.     OSErr                            scsiResult;
  457.     DeviceIdent                        scsiDevice;
  458.     SCSICallbackUPP                    scsiCompletion;
  459.     UInt32                            scsiFlags;
  460.     UInt8                            *scsiDriverStorage;
  461.     Ptr                                scsiXPTprivate;
  462.     long                            scsiReserved3;
  463.     UInt16                            scsiResultFlags;
  464.     UInt16                            scsiReserved3pt5;
  465.     UInt8                            *scsiDataPtr;
  466.     UInt32                            scsiDataLength;
  467.     UInt8                            *scsiSensePtr;
  468.     UInt8                            scsiSenseLength;
  469.     UInt8                            scsiCDBLength;
  470.     UInt16                            scsiSGListCount;
  471.     UInt32                            scsiReserved4;
  472.     UInt8                            scsiSCSIstatus;
  473.     SInt8                            scsiSenseResidual;
  474.     UInt16                            scsiReserved5;
  475.     long                            scsiDataResidual;
  476.     CDB                                scsiCDB;
  477.     long                            scsiTimeout;
  478.     UInt8                            *scsiReserved5pt5;
  479.     UInt16                            scsiReserved5pt6;
  480.     UInt16                            scsiIOFlags;
  481.     UInt8                            scsiTagAction;
  482.     UInt8                            scsiReserved6;
  483.     UInt16                            scsiReserved7;
  484.     UInt16                            scsiSelectTimeout;
  485.     UInt8                            scsiDataType;
  486.     UInt8                            scsiTransferType;
  487.     UInt32                            scsiReserved8;
  488.     UInt32                            scsiReserved9;
  489.     UInt16                            scsiHandshake[handshakeDataLength];
  490.     UInt32                            scsiReserved10;
  491.     UInt32                            scsiReserved11;
  492.     struct SCSI_IO                    *scsiCommandLink;
  493.     UInt8                            scsiSIMpublics[8];
  494.     UInt8                            scsiAppleReserved6[8];
  495.     UInt16                            scsiCurrentPhase;
  496.     short                            scsiSelector;
  497.     OSErr                            scsiOldCallResult;
  498.     UInt8                            scsiSCSImessage;
  499.     UInt8                            XPTprivateFlags;
  500.     UInt8                            XPTextras[12];
  501. };
  502. typedef struct SCSI_IO SCSI_IO;
  503.  
  504. typedef SCSI_IO SCSIExecIOPB;
  505.  
  506. /* Bus inquiry PB */
  507. struct SCSIBusInquiryPB {
  508.     struct SCSIHdr                    *qLink;
  509.     short                            scsiReserved1;
  510.     UInt16                            scsiPBLength;
  511.     UInt8                            scsiFunctionCode;
  512.     UInt8                            scsiReserved2;
  513.     OSErr                            scsiResult;
  514.     DeviceIdent                        scsiDevice;
  515.     SCSICallbackUPP                    scsiCompletion;
  516.     UInt32                            scsiFlags;
  517.     UInt8                            *scsiDriverStorage;
  518.     Ptr                                scsiXPTprivate;
  519.     long                            scsiReserved3;
  520.     UInt16                            scsiEngineCount;            /* <- Number of engines on HBA                         */
  521.     UInt16                            scsiMaxTransferType;        /* <- Number of transfer types for this HBA            */
  522.     UInt32                            scsiDataTypes;                /* <- which data types are supported by this SIM     */
  523.     UInt16                            scsiIOpbSize;                /* <- Size of SCSI_IO PB for this SIM/HBA             */
  524.     UInt16                            scsiMaxIOpbSize;            /* <- Size of max SCSI_IO PB for all SIM/HBAs         */
  525.     UInt32                            scsiFeatureFlags;            /* <- Supported features flags field                 */
  526.     UInt8                            scsiVersionNumber;            /* <- Version number for the SIM/HBA                 */
  527.     UInt8                            scsiHBAInquiry;                /* <- Mimic of INQ byte 7 for the HBA                 */
  528.     UInt8                            scsiTargetModeFlags;        /* <- Flags for target mode support                 */
  529.     UInt8                            scsiScanFlags;                /* <- Scan related feature flags                     */
  530.     UInt32                            scsiSIMPrivatesPtr;            /* <- Ptr to SIM private data area                     */
  531.     UInt32                            scsiSIMPrivatesSize;        /* <- Size of SIM private data area                 */
  532.     UInt32                            scsiAsyncFlags;                /* <- Event cap. for Async Callback                 */
  533.     UInt8                            scsiHiBusID;                /* <- Highest path ID in the subsystem              */
  534.     UInt8                            scsiInitiatorID;            /* <- ID of the HBA on the SCSI bus                 */
  535.     UInt16                            scsiBIReserved0;            /*                                                    */
  536.     UInt32                            scsiBIReserved1;            /* <-                                                  */
  537.     UInt32                            scsiFlagsSupported;            /* <- which scsiFlags are supported                 */
  538.     UInt16                            scsiIOFlagsSupported;        /* <- which scsiIOFlags are supported                 */
  539.     UInt16                            scsiWeirdStuff;                /* <-                                                 */
  540.     UInt16                            scsiMaxTarget;                /* <- maximum Target number supported                 */
  541.     UInt16                            scsiMaxLUN;                    /* <- maximum Logical Unit number supported         */
  542.     char                            scsiSIMVendor[vendorIDLength]; /* <- Vendor ID of SIM (or XPT if bus<FF)         */
  543.     char                            scsiHBAVendor[vendorIDLength]; /* <- Vendor ID of the HBA                         */
  544.     char                            scsiControllerFamily[vendorIDLength]; /* <- Family of SCSI Controller                 */
  545.     char                            scsiControllerType[vendorIDLength]; /* <- Specific Model of SCSI Controller used     */
  546.     char                            scsiXPTversion[4];            /* <- version number of XPT                         */
  547.     char                            scsiSIMversion[4];            /* <- version number of SIM                         */
  548.     char                            scsiHBAversion[4];            /* <- version number of HBA                         */
  549.     UInt8                            scsiHBAslotType;            /* <- type of "slot" that this HBA is in            */
  550.     UInt8                            scsiHBAslotNumber;            /* <- slot number of this HBA                         */
  551.     UInt16                            scsiSIMsRsrcID;                /* <- resource ID of this SIM                         */
  552.     UInt16                            scsiBIReserved3;            /* <-                                                 */
  553.     UInt16                            scsiAdditionalLength;        /* <- additional BusInquiry PB len                    */
  554. };
  555. typedef struct SCSIBusInquiryPB SCSIBusInquiryPB;
  556.  
  557. /* Abort SIM Request PB */
  558. struct SCSIAbortCommandPB {
  559.     struct SCSIHdr                    *qLink;
  560.     short                            scsiReserved1;
  561.     UInt16                            scsiPBLength;
  562.     UInt8                            scsiFunctionCode;
  563.     UInt8                            scsiReserved2;
  564.     OSErr                            scsiResult;
  565.     DeviceIdent                        scsiDevice;
  566.     SCSICallbackUPP                    scsiCompletion;
  567.     UInt32                            scsiFlags;
  568.     UInt8                            *scsiDriverStorage;
  569.     Ptr                                scsiXPTprivate;
  570.     long                            scsiReserved3;
  571.     SCSI_IO                            *scsiIOptr;                    /* Pointer to the PB to abort                        */
  572. };
  573. typedef struct SCSIAbortCommandPB SCSIAbortCommandPB;
  574.  
  575. /* Terminate I/O Process Request PB */
  576. struct SCSITerminateIOPB {
  577.     struct SCSIHdr                    *qLink;
  578.     short                            scsiReserved1;
  579.     UInt16                            scsiPBLength;
  580.     UInt8                            scsiFunctionCode;
  581.     UInt8                            scsiReserved2;
  582.     OSErr                            scsiResult;
  583.     DeviceIdent                        scsiDevice;
  584.     SCSICallbackUPP                    scsiCompletion;
  585.     UInt32                            scsiFlags;
  586.     UInt8                            *scsiDriverStorage;
  587.     Ptr                                scsiXPTprivate;
  588.     long                            scsiReserved3;
  589.     SCSI_IO                            *scsiIOptr;                    /* Pointer to the PB to terminate                     */
  590. };
  591. typedef struct SCSITerminateIOPB SCSITerminateIOPB;
  592.  
  593. /* Reset SCSI Bus PB */
  594. struct SCSIResetBusPB {
  595.     struct SCSIHdr                    *qLink;
  596.     short                            scsiReserved1;
  597.     UInt16                            scsiPBLength;
  598.     UInt8                            scsiFunctionCode;
  599.     UInt8                            scsiReserved2;
  600.     OSErr                            scsiResult;
  601.     DeviceIdent                        scsiDevice;
  602.     SCSICallbackUPP                    scsiCompletion;
  603.     UInt32                            scsiFlags;
  604.     UInt8                            *scsiDriverStorage;
  605.     Ptr                                scsiXPTprivate;
  606.     long                            scsiReserved3;
  607. };
  608. typedef struct SCSIResetBusPB SCSIResetBusPB;
  609.  
  610. /* Reset SCSI Device PB */
  611. struct SCSIResetDevicePB {
  612.     struct SCSIHdr                    *qLink;
  613.     short                            scsiReserved1;
  614.     UInt16                            scsiPBLength;
  615.     UInt8                            scsiFunctionCode;
  616.     UInt8                            scsiReserved2;
  617.     OSErr                            scsiResult;
  618.     DeviceIdent                        scsiDevice;
  619.     SCSICallbackUPP                    scsiCompletion;
  620.     UInt32                            scsiFlags;
  621.     UInt8                            *scsiDriverStorage;
  622.     Ptr                                scsiXPTprivate;
  623.     long                            scsiReserved3;
  624. };
  625. typedef struct SCSIResetDevicePB SCSIResetDevicePB;
  626.  
  627. /* Release SIM Queue PB */
  628. struct SCSIReleaseQPB {
  629.     struct SCSIHdr                    *qLink;
  630.     short                            scsiReserved1;
  631.     UInt16                            scsiPBLength;
  632.     UInt8                            scsiFunctionCode;
  633.     UInt8                            scsiReserved2;
  634.     OSErr                            scsiResult;
  635.     DeviceIdent                        scsiDevice;
  636.     SCSICallbackUPP                    scsiCompletion;
  637.     UInt32                            scsiFlags;
  638.     UInt8                            *scsiDriverStorage;
  639.     Ptr                                scsiXPTprivate;
  640.     long                            scsiReserved3;
  641. };
  642. typedef struct SCSIReleaseQPB SCSIReleaseQPB;
  643.  
  644. /* SCSI Get Virtual ID Info PB */
  645. struct SCSIGetVirtualIDInfoPB {
  646.     struct SCSIHdr                    *qLink;
  647.     short                            scsiReserved1;
  648.     UInt16                            scsiPBLength;
  649.     UInt8                            scsiFunctionCode;
  650.     UInt8                            scsiReserved2;
  651.     OSErr                            scsiResult;
  652.     DeviceIdent                        scsiDevice;
  653.     SCSICallbackUPP                    scsiCompletion;
  654.     UInt32                            scsiFlags;
  655.     UInt8                            *scsiDriverStorage;
  656.     Ptr                                scsiXPTprivate;
  657.     long                            scsiReserved3;
  658.     UInt16                            scsiOldCallID;                /* -> SCSI ID of device in question             */
  659.     Boolean                            scsiExists;                    /* <- true if device exists                     */
  660.     SInt8                            filler;
  661. };
  662. typedef struct SCSIGetVirtualIDInfoPB SCSIGetVirtualIDInfoPB;
  663.  
  664. /* Create/Lookup/Remove RefNum for Device PB */
  665. struct SCSIDriverPB {
  666.     struct SCSIHdr                    *qLink;
  667.     short                            scsiReserved1;
  668.     UInt16                            scsiPBLength;
  669.     UInt8                            scsiFunctionCode;
  670.     UInt8                            scsiReserved2;
  671.     OSErr                            scsiResult;
  672.     DeviceIdent                        scsiDevice;
  673.     SCSICallbackUPP                    scsiCompletion;
  674.     UInt32                            scsiFlags;
  675.     UInt8                            *scsiDriverStorage;
  676.     Ptr                                scsiXPTprivate;
  677.     long                            scsiReserved3;
  678.     short                            scsiDriver;                    /* -> DriverRefNum, For SetDriver, <- For GetNextDriver */
  679.     UInt16                            scsiDriverFlags;            /* <> Details of driver/device                     */
  680.     DeviceIdent                        scsiNextDevice;                /* <- DeviceIdent of the NEXT Item in the list  */
  681. };
  682. typedef struct SCSIDriverPB SCSIDriverPB;
  683.  
  684. /* Load Driver PB */
  685. struct SCSILoadDriverPB {
  686.     struct SCSIHdr                    *qLink;
  687.     short                            scsiReserved1;
  688.     UInt16                            scsiPBLength;
  689.     UInt8                            scsiFunctionCode;
  690.     UInt8                            scsiReserved2;
  691.     OSErr                            scsiResult;
  692.     DeviceIdent                        scsiDevice;
  693.     SCSICallbackUPP                    scsiCompletion;
  694.     UInt32                            scsiFlags;
  695.     UInt8                            *scsiDriverStorage;
  696.     Ptr                                scsiXPTprivate;
  697.     long                            scsiReserved3;
  698.     short                            scsiLoadedRefNum;            /* <- SIM returns refnum of driver                     */
  699.     Boolean                            scsiDiskLoadFailed;            /* -> if true, indicates call after failure to load */
  700.     SInt8                            filler;
  701. };
  702. typedef struct SCSILoadDriverPB SCSILoadDriverPB;
  703.  
  704. /* Defines for the scsiTransferType field */
  705.  
  706. enum {
  707.     scsiTransferBlind            = 0,
  708.     scsiTransferPolled
  709. };
  710.  
  711. /* Defines for the scsiDataType field */
  712. enum {
  713.     scsiDataBuffer                = 0,                            /* single contiguous buffer supplied                  */
  714.     scsiDataTIB                    = 1,                            /* TIB supplied (ptr in scsiDataPtr)                 */
  715.     scsiDataSG                    = 2                                /* scatter/gather list supplied                      */
  716. };
  717.  
  718. /* Defines for the SCSIMgr scsiResult field in the PB header. */
  719. /*  $E100 thru  E1FF */
  720. /* -$1EFF thru -1E00 */
  721. /* -#7935 thru -7681  */
  722. /* = 0xE100 */
  723. enum {
  724.     scsiErrorBase                = -7936
  725. };
  726.  
  727. enum {
  728.     scsiRequestInProgress        = 1,                            /* 1     = PB request is in progress             */
  729. /* Execution failed  00-2F */
  730.     scsiRequestAborted            = scsiErrorBase + 2,            /* -7934 = PB request aborted by the host         */
  731.     scsiUnableToAbort            = scsiErrorBase + 3,            /* -7933 = Unable to Abort PB request             */
  732.     scsiNonZeroStatus            = scsiErrorBase + 4,            /* -7932 = PB request completed with an err     */
  733.     scsiUnused05                = scsiErrorBase + 5,            /* -7931 =                                      */
  734.     scsiUnused06                = scsiErrorBase + 6,            /* -7930 =                                      */
  735.     scsiUnused07                = scsiErrorBase + 7,            /* -7929 =                                      */
  736.     scsiUnused08                = scsiErrorBase + 8,            /* -7928 =                                      */
  737.     scsiUnableToTerminate        = scsiErrorBase + 9,            /* -7927 = Unable to Terminate I/O PB req         */
  738.     scsiSelectTimeout            = scsiErrorBase + 10,            /* -7926 = Target selection timeout             */
  739.     scsiCommandTimeout            = scsiErrorBase + 11,            /* -7925 = Command timeout                      */
  740.     scsiIdentifyMessageRejected    = scsiErrorBase + 12,            /* -7924 =                                      */
  741.     scsiMessageRejectReceived    = scsiErrorBase + 13,            /* -7923 = Message reject received                 */
  742.     scsiSCSIBusReset            = scsiErrorBase + 14,            /* -7922 = SCSI bus reset sent/received         */
  743.     scsiParityError                = scsiErrorBase + 15,            /* -7921 = Uncorrectable parity error occured     */
  744.     scsiAutosenseFailed            = scsiErrorBase + 16,            /* -7920 = Autosense: Request sense cmd fail     */
  745.     scsiUnused11                = scsiErrorBase + 17,            /* -7919 =                                      */
  746.     scsiDataRunError            = scsiErrorBase + 18,            /* -7918 = Data overrun/underrun error          */
  747.     scsiUnexpectedBusFree        = scsiErrorBase + 19,            /* -7917 = Unexpected BUS free                     */
  748.     scsiSequenceFailed            = scsiErrorBase + 20,            /* -7916 = Target bus phase sequence failure     */
  749.     scsiWrongDirection            = scsiErrorBase + 21,            /* -7915 = Data phase was in wrong direction     */
  750.     scsiUnused16                = scsiErrorBase + 22,            /* -7914 =                                      */
  751.     scsiBDRsent                    = scsiErrorBase + 23,            /* -7913 = A SCSI BDR msg was sent to target     */
  752.     scsiTerminated                = scsiErrorBase + 24,            /* -7912 = PB request terminated by the host     */
  753.     scsiNoNexus                    = scsiErrorBase + 25,            /* -7911 = Nexus is not established             */
  754.     scsiCDBReceived                = scsiErrorBase + 26,            /* -7910 = The SCSI CDB has been received         */
  755. /* Couldn't begin execution  30-3F */
  756.     scsiTooManyBuses            = scsiErrorBase + 48,            /* -7888 = Register failed because we're full    */
  757.     scsiBusy                    = scsiErrorBase + 49,            /* -7887 = SCSI subsystem is busy                 */
  758.     scsiProvideFail                = scsiErrorBase + 50,            /* -7886 = Unable to provide requ. capability    */
  759.     scsiDeviceNotThere            = scsiErrorBase + 51,            /* -7885 = SCSI device not installed/there      */
  760.     scsiNoHBA                    = scsiErrorBase + 52,            /* -7884 = No HBA detected Error                 */
  761.     scsiDeviceConflict            = scsiErrorBase + 53,            /* -7883 = sorry, max 1 refNum per DeviceIdent     */
  762.     scsiNoSuchXref                = scsiErrorBase + 54,            /* -7882 = no such RefNum xref                     */
  763.     scsiQLinkInvalid            = scsiErrorBase + 55,            /* -7881 = pre-linked PBs not supported            
  764.                                                                    (The QLink field was nonzero)        */
  765. /* Parameter errors  40-7F */
  766.     scsiPBLengthError            = scsiErrorBase + 64,            /* -7872 = (scsiPBLength is insuf'ct/invalid     */
  767.     scsiFunctionNotAvailable    = scsiErrorBase + 65,            /* -7871 = The requ. func is not available      */
  768.     scsiRequestInvalid            = scsiErrorBase + 66,            /* -7870 = PB request is invalid                 */
  769.     scsiBusInvalid                = scsiErrorBase + 67,            /* -7869 = Bus ID supplied is invalid              */
  770.     scsiTIDInvalid                = scsiErrorBase + 68,            /* -7868 = Target ID supplied is invalid         */
  771.     scsiLUNInvalid                = scsiErrorBase + 69,            /* -7867 = LUN supplied is invalid              */
  772.     scsiIDInvalid                = scsiErrorBase + 70,            /* -7866 = The initiator ID is invalid          */
  773.     scsiDataTypeInvalid            = scsiErrorBase + 71,            /* -7865 = scsiDataType requested not supported */
  774.     scsiTransferTypeInvalid        = scsiErrorBase + 72,            /* -7864 = scsiTransferType field is too high     */
  775.     scsiCDBLengthInvalid        = scsiErrorBase + 73            /* -7863 = scsiCDBLength field is too big         */
  776. };
  777.  
  778. enum {
  779.     scsiExecutionErrors            = scsiErrorBase,
  780.     scsiNotExecutedErrors        = scsiTooManyBuses,
  781.     scsiParameterErrors            = scsiPBLengthError
  782. };
  783.  
  784. /* Defines for the scsiResultFlags field */
  785. enum {
  786.     scsiSIMQFrozen                = 0x0001,                        /* The SIM queue is frozen w/this err            */
  787.     scsiAutosenseValid            = 0x0002,                        /* Autosense data valid for target              */
  788.     scsiBusNotFree                = 0x0004                        /* At time of callback, SCSI bus is not free    */
  789. };
  790.  
  791. /* Defines for the bit numbers of the scsiFlags field in the PB header for the SCSIExecIO function */
  792. enum {
  793.     kbSCSIDisableAutosense        = 29,                            /* Disable auto sense feature                     */
  794.     kbSCSIFlagReservedA            = 28,                            /*                                              */
  795.     kbSCSIFlagReserved0            = 27,                            /*                                              */
  796.     kbSCSICDBLinked                = 26,                            /* The PB contains a linked CDB                    */
  797.     kbSCSIQEnable                = 25,                            /* Target queue actions are enabled                */
  798.     kbSCSICDBIsPointer            = 24,                            /* The CDB field contains a pointer                */
  799.     kbSCSIFlagReserved1            = 23,                            /*                                                 */
  800.     kbSCSIInitiateSyncData        = 22,                            /* Attempt Sync data xfer and SDTR                */
  801.     kbSCSIDisableSyncData        = 21,                            /* Disable sync, go to async                    */
  802.     kbSCSISIMQHead                = 20,                            /* Place PB at the head of SIM Q                */
  803.     kbSCSISIMQFreeze            = 19,                            /* Return the SIM Q to frozen state                */
  804.     kbSCSISIMQNoFreeze            = 18,                            /* Disallow SIM Q freezing                        */
  805.     kbSCSIDoDisconnect            = 17,                            /* Definitely do disconnect                        */
  806.     kbSCSIDontDisconnect        = 16,                            /* Definitely don't disconnect                    */
  807.     kbSCSIDataReadyForDMA        = 15,                            /* Data buffer(s) are ready for DMA                */
  808.     kbSCSIFlagReserved3            = 14,                            /*                                                 */
  809.     kbSCSIDataPhysical            = 13,                            /* SG/Buffer data ptrs are physical                */
  810.     kbSCSISensePhysical            = 12,                            /* Autosense buffer ptr is physical                */
  811.     kbSCSIFlagReserved5            = 11,                            /*                                                 */
  812.     kbSCSIFlagReserved6            = 10,                            /*                                                 */
  813.     kbSCSIFlagReserved7            = 9,                            /*                                                 */
  814.     kbSCSIFlagReserved8            = 8,                            /*                                                 */
  815.     kbSCSIDataBufferValid        = 7,                            /* Data buffer valid                            */
  816.     kbSCSIStatusBufferValid        = 6,                            /* Status buffer valid                             */
  817.     kbSCSIMessageBufferValid    = 5,                            /* Message buffer valid                            */
  818.     kbSCSIFlagReserved9            = 4                                /*                                              */
  819. };
  820.  
  821. /* Defines for the bit masks of the scsiFlags field */
  822. enum {
  823.     scsiDirectionMask            = 0xC0000000,                    /* Data direction mask                        */
  824.     scsiDirectionNone            = 0xC0000000,                    /* Data direction (11: no data)                */
  825.     scsiDirectionReserved        = 0x00000000,                    /* Data direction (00: reserved)            */
  826.     scsiDirectionOut            = 0x80000000,                    /* Data direction (10: DATA OUT)            */
  827.     scsiDirectionIn                = 0x40000000,                    /* Data direction (01: DATA IN)                */
  828.     scsiDisableAutosense        = 0x20000000,                    /* Disable auto sense feature                */
  829.     scsiFlagReservedA            = 0x10000000,                    /*                                             */
  830.     scsiFlagReserved0            = 0x08000000,                    /*                                             */
  831.     scsiCDBLinked                = 0x04000000,                    /* The PB contains a linked CDB                */
  832.     scsiQEnable                    = 0x02000000,                    /* Target queue actions are enabled            */
  833.     scsiCDBIsPointer            = 0x01000000,                    /* The CDB field contains a pointer            */
  834.     scsiFlagReserved1            = 0x00800000,                    /*                                             */
  835.     scsiInitiateSyncData        = 0x00400000,                    /* Attempt Sync data xfer and SDTR            */
  836.     scsiDisableSyncData            = 0x00200000,                    /* Disable sync, go to async                */
  837.     scsiSIMQHead                = 0x00100000,                    /* Place PB at the head of SIM Q            */
  838.     scsiSIMQFreeze                = 0x00080000,                    /* Return the SIM Q to frozen state            */
  839.     scsiSIMQNoFreeze            = 0x00040000,                    /* Disallow SIM Q freezing                    */
  840.     scsiDoDisconnect            = 0x00020000,                    /* Definitely do disconnect                    */
  841.     scsiDontDisconnect            = 0x00010000,                    /* Definitely don't disconnect                */
  842.     scsiDataReadyForDMA            = 0x00008000,                    /* Data buffer(s) are ready for DMA            */
  843.     scsiFlagReserved3            = 0x00004000,                    /*  */
  844.     scsiDataPhysical            = 0x00002000,                    /* SG/Buffer data ptrs are physical            */
  845.     scsiSensePhysical            = 0x00001000,                    /* Autosense buffer ptr is physical            */
  846.     scsiFlagReserved5            = 0x00000800,                    /*                                          */
  847.     scsiFlagReserved6            = 0x00000400,                    /*                                             */
  848.     scsiFlagReserved7            = 0x00000200,                    /*                                             */
  849.     scsiFlagReserved8            = 0x00000100                    /*                                             */
  850. };
  851.  
  852. /* bit masks for the scsiIOFlags field in SCSIExecIOPB */
  853. enum {
  854.     scsiNoParityCheck            = 0x0002,                        /* disable parity checking                             */
  855.     scsiDisableSelectWAtn        = 0x0004,                        /* disable select w/Atn                              */
  856.     scsiSavePtrOnDisconnect        = 0x0008,                        /* do SaveDataPointer upon Disconnect msg             */
  857.     scsiNoBucketIn                = 0x0010,                        /* don’t bit bucket in during this I/O                 */
  858.     scsiNoBucketOut                = 0x0020,                        /* don’t bit bucket out during this I/O             */
  859.     scsiDisableWide                = 0x0040,                        /* disable wide transfer negotiation                 */
  860.     scsiInitiateWide            = 0x0080,                        /* initiate wide transfer negotiation                 */
  861.     scsiRenegotiateSense        = 0x0100,                        /* renegotiate sync/wide before issuing autosense     */
  862.     scsiDisableDiscipline        = 0x0200,                        /* disable parameter checking on SCSIExecIO calls    */
  863.     scsiIOFlagReserved0080        = 0x0080,                        /*                                                  */
  864.     scsiIOFlagReserved8000        = 0x8000                        /*                                                     */
  865. };
  866.  
  867. /* Defines for the SIM/HBA queue actions.  These values are used in the */
  868. /* SCSIExecIOPB, for the queue action field. [These values should match the */
  869. /* defines from some other include file for the SCSI message phases.  We may */
  870. /* not need these definitions here. ] */
  871. enum {
  872.     scsiSimpleQTag                = 0x20,                            /* Tag for a simple queue                                 */
  873.     scsiHeadQTag                = 0x21,                            /* Tag for head of queue                                  */
  874.     scsiOrderedQTag                = 0x22                            /* Tag for ordered queue                                 */
  875. };
  876.  
  877. /* Defines for the Bus Inquiry PB fields. */
  878. /* scsiHBAInquiry field bits */
  879. enum {
  880.     scsiBusMDP                    = 0x80,                            /* Supports Modify Data Pointer message                        */
  881.     scsiBusWide32                = 0x40,                            /* Supports 32 bit wide SCSI                                */
  882.     scsiBusWide16                = 0x20,                            /* Supports 16 bit wide SCSI                                */
  883.     scsiBusSDTR                    = 0x10,                            /* Supports Sync Data Transfer Req message                    */
  884.     scsiBusLinkedCDB            = 0x08,                            /* Supports linked CDBs                                        */
  885.     scsiBusTagQ                    = 0x02,                            /* Supports tag queue message                                */
  886.     scsiBusSoftReset            = 0x01                            /* Supports soft reset                                        */
  887. };
  888.  
  889. /* scsiDataTypes field bits  */
  890. /*    bits 0->15 Apple-defined, 16->30 3rd-party unique, 31 = reserved */
  891. enum {
  892.     scsiBusDataTIB                = (1 << scsiDataTIB),            /* TIB supplied (ptr in scsiDataPtr)        */
  893.     scsiBusDataBuffer            = (1 << scsiDataBuffer),        /* single contiguous buffer supplied         */
  894.     scsiBusDataSG                = (1 << scsiDataSG),            /* scatter/gather list supplied             */
  895.     scsiBusDataReserved            = 0x80000000                    /*                                           */
  896. };
  897.  
  898. /* scsiScanFlags field bits */
  899. enum {
  900.     scsiBusScansDevices            = 0x80,                            /* Bus scans for and maintains device list            */
  901.     scsiBusScansOnInit            = 0x40,                            /* Bus scans performed at power-up/reboot            */
  902.     scsiBusLoadsROMDrivers        = 0x20                            /* may load ROM drivers to support targets             */
  903. };
  904.  
  905. /* scsiFeatureFlags field bits */
  906. enum {
  907.     scsiBusInternalExternalMask    = 0x000000C0,                    /* bus internal/external mask                    */
  908.     scsiBusInternalExternalUnknown = 0x00000000,                /* not known whether bus is inside or outside     */
  909.     scsiBusInternalExternal        = 0x000000C0,                    /* bus goes inside and outside the box             */
  910.     scsiBusInternal                = 0x00000080,                    /* bus goes inside the box                         */
  911.     scsiBusExternal                = 0x00000040,                    /* bus goes outside the box                     */
  912.     scsiBusCacheCoherentDMA        = 0x00000020,                    /* DMA is cache coherent                         */
  913.     scsiBusOldCallCapable        = 0x00000010,                    /* SIM is old call capable                         */
  914.     scsiBusDifferential            = 0x00000004,                    /* Single Ended (0) or Differential (1)         */
  915.     scsiBusFastSCSI                = 0x00000002,                    /* HBA supports fast SCSI                         */
  916.     scsiBusDMAavailable            = 0x00000001                    /* DMA is available                             */
  917. };
  918.  
  919. /* scsiWeirdStuff field bits */
  920. enum {
  921.     scsiOddDisconnectUnsafeRead1 = 0x0001,                        /* Disconnects on odd byte boundries are unsafe with DMA and/or blind reads */
  922.     scsiOddDisconnectUnsafeWrite1 = 0x0002,                        /* Disconnects on odd byte boundries are unsafe with DMA and/or blind writes */
  923.     scsiBusErrorsUnsafe            = 0x0004,                        /* Non-handshaked delays or disconnects during blind transfers may cause a crash */
  924.     scsiRequiresHandshake        = 0x0008,                        /* Non-handshaked delays or disconnects during blind transfers may cause data corruption */
  925.     scsiTargetDrivenSDTRSafe    = 0x0010,                        /* Targets which initiate synchronous negotiations are supported */
  926.     scsiOddCountForPhysicalUnsafe = 0x0020                        /* If using physical addrs all counts must be even, and disconnects must be on even boundries */
  927. };
  928.  
  929. /* scsiHBAslotType values */
  930. enum {
  931.     scsiMotherboardBus            = 0x01,                            /* A built in Apple supplied bus                     */
  932.     scsiNuBus                    = 0x02,                            /* A SIM on a NuBus card                             */
  933.     scsiPDSBus                    = 0x03,                            /*    "  on a PDS card                                */
  934.     scsiPCIBus                    = 0x04,                            /*    "  on a PCI bus card                            */
  935.     scsiPCMCIABus                = 0x05,                            /*    "  on a PCMCIA card                            */
  936.     scsiFireWireBridgeBus        = 0x06                            /*    "  connected through a FireWire bridge        */
  937. };
  938.  
  939. /* Defines for the scsiDriverFlags field (in SCSIDriverPB) */
  940. enum {
  941.     scsiDeviceSensitive            = 0x0001,                        /* Only driver should access this device                */
  942.     scsiDeviceNoOldCallAccess    = 0x0002                        /* no old call access to this device                     */
  943. };
  944.  
  945. /*  SIMInitInfo PB */
  946. /* directions are for SCSIRegisterBus call ( -> parm, <- result)             */
  947. struct SIMInitInfo {
  948.     UInt8                            *SIMstaticPtr;                /* <- alloc. ptr to the SIM's static vars                 */
  949.     long                            staticSize;                    /* -> num bytes SIM needs for static vars                 */
  950.     SIMInitUPP                        SIMInit;                    /* -> pointer to the SIM init routine                     */
  951.     SIMActionUPP                    SIMAction;                    /* -> pointer to the SIM action routine                 */
  952.     SCSIInterruptUPP                SIM_ISR;                    /*       reserved                                             */
  953.     SCSIInterruptUPP                SIMInterruptPoll;            /* -> pointer to the SIM interrupt poll routine            */
  954.     SIMActionUPP                    NewOldCall;                    /* -> pointer to the SIM NewOldCall routine                */
  955.     UInt16                            ioPBSize;                    /* -> size of SCSI_IO_PBs required for this SIM            */
  956.     Boolean                            oldCallCapable;                /* -> true if this SIM can handle old-API calls            */
  957.     UInt8                            simInfoUnused1;                /*       reserved                                            */
  958.     long                            simInternalUse;                /* xx not affected or viewed by XPT                        */
  959.     SCSIUPP                            XPT_ISR;                    /*    reserved                                            */
  960.     SCSIUPP                            EnteringSIM;                /* <- ptr to the EnteringSIM routine                    */
  961.     SCSIUPP                            ExitingSIM;                    /* <- ptr to the ExitingSIM routine                        */
  962.     SCSIMakeCallbackUPP                MakeCallback;                /* <- the XPT layer’s SCSIMakeCallback routine            */
  963.     UInt16                            busID;                        /* <- bus number for the registered bus                    */
  964.     UInt8                            simSlotNumber;                /* <- Magic cookie to place in scsiHBASlotNumber (PCI)    */
  965.     UInt8                            simSRsrcID;                    /* <- Magic cookie to place in scsiSIMsRsrcID     (PCI)    */
  966.     Ptr                                simRegEntry;                /* -> The SIM's RegEntryIDPtr                     (PCI)    */
  967. };
  968. typedef struct SIMInitInfo SIMInitInfo;
  969.  
  970. /* Glue between SCSI calls and SCSITrap format */
  971.  
  972. enum {
  973.     xptSCSIAction                = 0x0001,
  974.     xptSCSIRegisterBus            = 0x0002,
  975.     xptSCSIDeregisterBus        = 0x0003,
  976.     xptSCSIReregisterBus        = 0x0004,
  977.     xptSCSIKillXPT                = 0x0005,                        /* kills Mini-XPT after transition */
  978.     xptSCSIInitialize            = 0x000A                        /* Initialize the SCSI manager */
  979. };
  980.  
  981. /* SCSI status*/
  982. enum {
  983.     scsiStatGood                = 0x00,                            /* Good Status*/
  984.     scsiStatCheckCondition        = 0x02,                            /* Check Condition*/
  985.     scsiStatConditionMet        = 0x04,                            /* Condition Met*/
  986.     scsiStatBusy                = 0x08,                            /* Busy*/
  987.     scsiStatIntermediate        = 0x10,                            /* Intermediate*/
  988.     scsiStatIntermedMet            = 0x14,                            /* Intermediate - Condition Met*/
  989.     scsiStatResvConflict        = 0x18,                            /* Reservation conflict*/
  990.     scsiStatTerminated            = 0x20,                            /* Command terminated*/
  991.     scsiStatQFull                = 0x28                            /* Queue full*/
  992. };
  993.  
  994. /* SCSI messages*/
  995. enum {
  996.     kCmdCompleteMsg                = 0,
  997.     kExtendedMsg,                                                /* 0x01*/
  998.     kSaveDataPointerMsg,                                        /* 0x02*/
  999.     kRestorePointersMsg,                                        /* 0x03*/
  1000.     kDisconnectMsg,                                                /* 0x04*/
  1001.     kInitiatorDetectedErrorMsg,                                    /* 0x05*/
  1002.     kAbortMsg,                                                    /* 0x06*/
  1003.     kMsgRejectMsg,                                                /* 0x07*/
  1004.     kNoOperationMsg,                                            /* 0x08*/
  1005.     kMsgParityErrorMsg,                                            /* 0x09*/
  1006.     kLinkedCmdCompleteMsg,                                        /* 0x0a*/
  1007.     kLinkedCmdCompleteWithFlagMsg,                                /* 0x0b*/
  1008.     kBusDeviceResetMsg,                                            /* 0x0c*/
  1009.     kAbortTagMsg,                                                /* 0x0d*/
  1010.     kClearQueueMsg,                                                /* 0x0e*/
  1011.     kInitiateRecoveryMsg,                                        /* 0x0f*/
  1012.     kReleaseRecoveryMsg,                                        /* 0x10*/
  1013.     kTerminateIOProcessMsg,                                        /* 0x11*/
  1014.     kSimpleQueueTag                = 0x20,                            /* 0x20*/
  1015.     kHeadOfQueueTagMsg,                                            /* 0x21*/
  1016.     kOrderedQueueTagMsg,                                        /* 0x22*/
  1017.     kIgnoreWideResidueMsg                                        /* 0x23*/
  1018. };
  1019.  
  1020. /* moveq #kSCSIx, D0;  _SCSIAtomic */
  1021.  
  1022. #if !GENERATINGCFM
  1023. #pragma parameter __D0 SCSIAction(__A0)
  1024. #endif
  1025. extern pascal OSErr SCSIAction(SCSI_PB *parameterBlock)
  1026.  TWOWORDINLINE(0x7001, 0xA089);
  1027.  
  1028. #if !GENERATINGCFM
  1029. #pragma parameter __D0 SCSIRegisterBus(__A0)
  1030. #endif
  1031. extern pascal OSErr SCSIRegisterBus(SIMInitInfo *parameterBlock)
  1032.  TWOWORDINLINE(0x7002, 0xA089);
  1033.  
  1034. #if !GENERATINGCFM
  1035. #pragma parameter __D0 SCSIDeregisterBus(__A0)
  1036. #endif
  1037. extern pascal OSErr SCSIDeregisterBus(SCSI_PB *parameterBlock)
  1038.  TWOWORDINLINE(0x7003, 0xA089);
  1039.  
  1040. #if !GENERATINGCFM
  1041. #pragma parameter __D0 SCSIReregisterBus(__A0)
  1042. #endif
  1043. extern pascal OSErr SCSIReregisterBus(SIMInitInfo *parameterBlock)
  1044.  TWOWORDINLINE(0x7004, 0xA089);
  1045.  
  1046. #if !GENERATINGCFM
  1047. #pragma parameter __D0 SCSIKillXPT(__A0)
  1048. #endif
  1049. extern pascal OSErr SCSIKillXPT(SIMInitInfo *parameterBlock)
  1050.  TWOWORDINLINE(0x7005, 0xA089);
  1051.  
  1052. #if PRAGMA_IMPORT_SUPPORTED
  1053. #pragma import off
  1054. #endif
  1055.  
  1056. #if PRAGMA_ALIGN_SUPPORTED
  1057. #pragma options align=reset
  1058. #endif
  1059.  
  1060. #ifdef __cplusplus
  1061. }
  1062. #endif
  1063.  
  1064. #endif /* __SCSI__ */
  1065.